home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13078 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: newshost.centrum.is!news
  2. From: bjarnir@centrum.is (Bjarni Ragnarsson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Advanced C++ question...
  5. Date: 23 Mar 1996 13:26:26 GMT
  6. Organization: BR Software
  7. Message-ID: <4j0u62$6na@newshost.centrum.is>
  8. References: <4iprfg$1ui@aadt> <DoMH88.5wv@mv.mv.com>
  9. NNTP-Posting-Host: tungl-51.centrum.is
  10. X-Newsreader: WinVN version 0.82
  11.  
  12. In article <DoMH88.5wv@mv.mv.com>, ENGR@GSSI.MV.COM (Michael Furman) says:
  13. >
  14. >In article <4iprfg$1ui@aadt>, david_hooker@sdt.com says...
  15. >>
  16. >>Hi all...
  17. >>
  18. >>I want to write an operator* for a class, but I want to do
  19. >>one of 2 things:
  20. >>   1. Call one of two different operator*'s depending on whether
  21. >>      it is an lvalue or rvalue
  22. >>   OR
  23. >>   2. Somehow determine in the function if it is being used as an
  24. >>      lvalue or an rvalue.
  25. >>
  26. >>For instance, I want to know, in the operator*, from which case I'm
  27. >>being called:
  28. >>
  29. >>  *Object = SomeValue;     // used as an lvalue
  30. >>
  31. >>   SomeValue = *Object;    // used as an rvalue
  32. >>
  33. >>
  34. >>The reason for this is that this class accesses data differently 
  35. >depending
  36. >>on if it is a read or write access.
  37. >
  38. >It is impossible with "*" operator. But you can define conversion 
  39. >functions
  40. >for your class - it will allow exactly what you need.
  41. >
  42.  
  43. Could you explain this a bit further.  I have a similar problem to solve.
  44.  
  45. Thanks, 
  46. Bjarni Ragnarsson
  47. bjarnir@centrum.is
  48.